package com.naodong.shenluntiku.mvp.model.data.api;

import com.naodong.shenluntiku.BuildConfig;
import com.naodong.shenluntiku.mvp.model.bean.Analysis;
import com.naodong.shenluntiku.mvp.model.bean.Assessment;
import com.naodong.shenluntiku.mvp.model.bean.Banner;
import com.naodong.shenluntiku.mvp.model.bean.BaseBean;
import com.naodong.shenluntiku.mvp.model.bean.CollectDetail;
import com.naodong.shenluntiku.mvp.model.bean.CollectType;
import com.naodong.shenluntiku.mvp.model.bean.GradeChartData;
import com.naodong.shenluntiku.mvp.model.bean.IdAndCon;
import com.naodong.shenluntiku.mvp.model.bean.LoginInfo;
import com.naodong.shenluntiku.mvp.model.bean.NoticeSet;
import com.naodong.shenluntiku.mvp.model.bean.PagingBean;
import com.naodong.shenluntiku.mvp.model.bean.ResponseMsg;
import com.naodong.shenluntiku.mvp.model.bean.Study;
import com.naodong.shenluntiku.mvp.model.bean.StudySet;
import com.naodong.shenluntiku.mvp.model.bean.SubjectInfo;
import com.naodong.shenluntiku.mvp.model.bean.SubjectType;
import com.naodong.shenluntiku.mvp.model.bean.UserInfo;
import com.naodong.shenluntiku.mvp.model.bean.VerCode;

import java.util.List;

import io.reactivex.Observable;
import me.shingohu.man.intergation.retrofit.NoBodyEntity;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * Created by hujie on 17/4/15.
 */

public interface CommonApi {
    String APP_URL = BuildConfig.APP_URL;

    //获取视频解析列表
    @GET
    Observable<PagingBean<List<Analysis>>> getVideoAnalysisList(@Url String url);


    @FormUrlEncoded
    @POST("api/login")
    Observable<BaseBean<LoginInfo>> login(@Field("phone") String userName, @Field("phoneCode") String password, @Field("deviceNum") String deviceNum, @Field("deviceName") String deviceName);

    @GET("api/subjectType")
    Observable<BaseBean<List<SubjectType>>> getFindSubjectItems();

    @GET("api/subjectType/{subTypeId}/uData")
    Observable<BaseBean<GradeChartData>> getFindSubjectItemGradeChartData(@Path("subTypeId") int subTypeId);

    @GET("api/subjectType/{subTypeId}/assess/doing")
    Observable<BaseBean<Assessment>> getAssessmentFromFind(@Path("subTypeId") int subTypeId);

    @GET("api/userRec/rc/{rcId}/assess")
    Observable<BaseBean<Assessment>> getAssessmentFromStudy(@Path("rcId") int reId);


    @POST("api/assess/{assessId}/answers")
    Observable<BaseBean<Assessment>> submitAssessment(@Path("assessId") int assessId, @Body List<SubjectInfo> subjectInfos);


    @GET
    Observable<PagingBean<List<Analysis>>> getSubjectAnalysisList(@Url String url);


    @FormUrlEncoded
    @POST("api/favourite")
    Observable<NoBodyEntity> postCollect(@Field("resourceId") int resourceId, @Field("favourTypeId") int favourTypeId);


    @DELETE("api/favourite")
    Observable<NoBodyEntity> deleteCollect(@Query("resourceId") int resourceId, @Query("favourTypeId") int favourTypeId);


    @GET("api/advert")
    Observable<BaseBean<List<Banner>>> getBanner();


    @FormUrlEncoded
    @POST("api/feedback")
    Observable<NoBodyEntity> feedback(@Field("con") String con, @Field("contact") String contact, @Field("imageUrl") String imageUrl);

    @GET("api/favourite/types")
    Observable<BaseBean<List<CollectType>>> collectTypes();


    @GET
    Observable<PagingBean<List<CollectDetail>>> collectList(@Url String url);


    @GET
    Observable<PagingBean<List<SubjectInfo>>> subjectHistoryList(@Url String url);

    @GET
    Observable<PagingBean<List<SubjectInfo>>> subjectWrongList(@Url String url);


    //获取验证码
    @GET("api/getCode")
    Observable<BaseBean<VerCode>> getVerCode(@Query("phone") String phone, @Query("numCode") String numCode);

    @GET("api/safeQuestions")
    Observable<BaseBean<List<IdAndCon>>> getSafeVerQs();


    @FormUrlEncoded
    @POST("api/userSafeQuestion")
    Observable<BaseBean<ResponseMsg>> saveSafeVerQuestion(@Field("id") int id, @Field("con") String con);

    @FormUrlEncoded
    @POST("api/checkSafeQuestion")
    Observable<BaseBean<ResponseMsg>> checkSafeVerQuestion(@Field("id") int id, @Field("con") String con);

    @PUT("api/trustClient")
    Observable<BaseBean<ResponseMsg>> trustClient(@Query("id") int id);


    @FormUrlEncoded
    @POST("api/setUserNickname")
    Observable<NoBodyEntity> editUserName(@Field("nickname") String nickname);


    @GET("api/userInfo")
    Observable<BaseBean<UserInfo>> getUserInfo();


    @FormUrlEncoded
    @POST("api/setUserAvatar")
    Observable<BaseBean<String>> editUserAvatar(@Field("avatar") String avatar);


    @GET("api/userRecSetting")
    Observable<BaseBean<StudySet>> getStudySet();

    @FormUrlEncoded
    @POST("api/userRecSetting")
    Observable<NoBodyEntity> updateStudySet(@Field("type") String type, @Field("isChosen") int isChosen, @Field("value") String vaule);


    @GET
    Observable<PagingBean<List<Study>>> getStudys(@Url String url);


    @POST("api/userRec/rc/{rcId}/finish")
    Observable<NoBodyEntity> setRead(@Path("rcId") int rcId);


    //获取督学提醒设置
    @POST("api/getTipStatus")
    Observable<BaseBean<NoticeSet>> getNoticeSet();


    @FormUrlEncoded
    @POST("api/setTipTime")
    Observable<NoBodyEntity> setNoticeTime(@Field("time") String time);


    @POST("api/setTipSwitch")
    Observable<NoBodyEntity> setNoticeSwitch();


}
